Text Loops by Zed Lopez

Version 1

"Loop through characters, words, lines, or paragraphs in a text."
Jump to extension code

Error

Includes and Included by are omitted for modules with errors

ni

In Volume intfiction.org/t/46906 in the extension 6M62 Patches by Friends Of
I7:


You wrote 'Include (- [ Relation_ShowOtoO relation sym x [...] j2);
print "^"; } } } ]; -) instead of "Show One to One" in "Relations.i6t"' 6m62 patches by friends
of i7: but this syntax was withdrawn in April
2022, in favour of a more finely controlled inclusion command. See the
manual, but you can probably get what you want using 'replacing
"SomeFunctionName".' rather than 'instead of ...'.
In Volume https://intfiction.org/t/53835/4 in the extension 6M62 Patches by
Friends Of I7:


You wrote 'Include (- Array Flex_Heap -> MEMORY_HEAP_SIZ [...] ; ! allow
room for head-free-block -) instead of "The Heap" in "Flex.i6t"' 6m62 patches by friends
of i7: again, this syntax was withdrawn in
April 2022.


You wrote 'Include (- [ HeapInitialise n bsize blk2; [...]
blk2-->BLK_PREV = Flex_Heap; ]; -) instead of "Initialisation" in
"Flex.i6t"' 6m62
patches by friends of i7: again, this syntax was withdrawn in April 2022.
Copy Include Text Loops by Zed Lopez to clipboard Include Text Loops by Zed Lopez.
This is experimental and mostly made out of the undocumented features in the Standard Rules the docs call on us not to use.

Ways you can also loop through text (uword = unpunctuated word; pword = punctuated word):

```
repeat with ch running through characters in T:
repeat with w running through words in T:
repeat with uw running through uwords in T:
repeat with pw running through pwords in T:
repeat with line running through lines in T:
repeat with p running through paragraphs in T:
```

"Characters" may be abbreviated as "chars" and all of the above can also have an index specified:

```
repeat for ch in chars of T with index i;
```
Version 1 of Text Loops by Zed Lopez begins here.

"Loop through characters, words, lines, or paragraphs in a text."

Include 6M62 Patches by Friends of I7. [ need TEXT_TY_BlobAccess fix ]

Book Text manipulation

Part Characters

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in chars/characters in/of (T - text) with/using index (index - nonexisting number variable) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, CHR_BLOB);
for ( {index} = 1 : {index} <= {-my:1} : {index}++)
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {index}, CHR_BLOB)))
-)

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in chars/characters in/of (T - text) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, CHR_BLOB);
for ( {-my:2} = 1 : {-my:2} <= {-my:1} : {-my:2}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {-my:2}, CHR_BLOB)))
-)

Part Words

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in words in/of (T - text) with/using index (index - nonexisting number variable) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, WORD_BLOB);
for ( {index} = 1 : {index} <= {-my:1} : {index}++)
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {index}, WORD_BLOB)))
-)

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in words in/of (T - text) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, WORD_BLOB);
for ( {-my:2} = 1 : {-my:2} <= {-my:1} : {-my:2}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {-my:2}, WORD_BLOB)))
-)

Part Pwords

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in pwords in/of (T - text) with/using index (index - nonexisting number variable) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, PWORD_BLOB);
for ( {index} = 1 : {index} <= {-my:1} : {index}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {index}, PWORD_BLOB)))
-)

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in pwords in/of (T - text) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, PWORD_BLOB);
for ( {-my:2} = 1 : {-my:2} <= {-my:1} : {-my:2}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {-my:2}, PWORD_BLOB)))
-)

Part Uwords

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in uwords in/of (T - text) with/using index (index - nonexisting number variable) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, UWORD_BLOB);
for ( {index} = 1 : {index} <= {-my:1} : {index}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {index}, UWORD_BLOB)))
-)

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in uwords in/of (T - text) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, UWORD_BLOB);
for ( {-my:2} = 1 : {-my:2} <= {-my:1} : {-my:2}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {-my:2}, UWORD_BLOB)))
-)

Part Lines

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in lines in/of (T - text) with/using index (index - nonexisting number variable) begin -- end loop:
     (-
{-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, LINE_BLOB);
for ( {index} = 1 : {index} <= {-my:1} : {index}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {index}, LINE_BLOB)))
-)

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in lines in/of (T - text) begin -- end loop:
     (-
{-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, LINE_BLOB);
for ( {-my:2} = 1 : {-my:2} <= {-my:1} : {-my:2}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {-my:2}, LINE_BLOB)))
-)

Part Paragraphs

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in paragraphs in/of (T - text) with/using index (index - nonexisting number variable) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, PARA_BLOB);
for ( {index} = 1 : {index} <= {-my:1} : {index}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {index}, PARA_BLOB)))
-)

To repeat with/for (loopvar - nonexisting text variable) running/-- through/in paragraphs in/of (T - text) begin -- end loop:
     (- {-my:1} = TEXT_TY_BlobAccess({-by-reference:T}, PARA_BLOB);
for ( {-my:2} = 1 : {-my:2} <= {-my:1} : {-my:2}++ )
if (BlkValueCopy({-by-reference:loopvar}, TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {-my:2}, PARA_BLOB)))
-)

Text Loops ends here.